package com.handtransaction.entity;

import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class Goods {
    private Integer gid;
    private String gname;
    private Integer guid;
    //上架时间
    //getGtime()返回String
    private Date gtime;
    private BigDecimal gprice;
    private Integer gnumber;
    private String gcid;       //商品类别
    private String gdetail;
    private String guname;
    private MultipartFile gimgfile;
    private String gimg_path;  //商品图片地址
    private int gtinyint;

    public int getGtinyint() {
        return gtinyint;
    }

    public void setGtinyint(int gtinyint) {
        this.gtinyint = gtinyint;
    }

    public void setImgfile(MultipartFile gimgfile) {
        this.gimgfile = gimgfile;
    }

    public String getGimg_path() {
        return gimg_path;
    }

    public void setGimg_path(String gimg_path) {
        this.gimg_path = gimg_path;
    }

    public MultipartFile getGimgfile() {
        return gimgfile;
    }
    public Goods() {

    }

    public Goods(Integer gnumber, String gcid) {
        this.gnumber = gnumber;
        this.gcid = gcid;
    }

    public String getGuname() {
        return guname;
    }

    public void setGuname(String guname) {
        this.guname = guname;
    }

    public Goods(Integer gid, String gname, Integer guid, Date gtime, BigDecimal gprice, Integer gnumber, String gcid, String gdetail, String guname, String gimg_path) {
        this.gid = gid;
        this.gname = gname;
        this.guid = guid;
        this.gtime = gtime;
        this.gprice = gprice;
        this.gnumber = gnumber;
        this.gcid = gcid;
        this.gdetail = gdetail;
        this.guname = guname;
        this.gimg_path = gimg_path;
    }

    public Goods(Integer gid, String gname, Integer guid, Date gtime, BigDecimal gprice, Integer gnumber, String gcid, String gdetail, String guname, String gimg_path,int gtinyint) {
        this.gid = gid;
        this.gname = gname;
        this.guid = guid;
        this.gtime = gtime;
        this.gprice = gprice;
        this.gnumber = gnumber;
        this.gcid = gcid;
        this.gdetail = gdetail;
        this.guname = guname;
        this.gimg_path = gimg_path;
        this.gtinyint = gtinyint;
    }

    public int getGid() {
        return gid;
    }

    public void setGid(int gid) {
        this.gid = gid;
    }

    public String getGname() {
        return gname;
    }

    public void setGname(String gname) {
        this.gname = gname;
    }

    public int getGuid() {
        return guid;
    }

    public void setGuid(int guid) {
        this.guid = guid;
    }

    public String getGtime() {
        String value = null;
        //将Date类型的时间转换成指定格式的字符串
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        value = dateFormat.format(this.gtime);
        return value;
    }


    public void setGtime(String gtime) {
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        ParsePosition pos = new ParsePosition(0);//从第一个字符开始解析
        this.gtime = f.parse(gtime, pos);
    }

    public void setGtime() {
        Date date = new Date();
        this.gtime = date;
    }

    public BigDecimal getGprice() {
        return gprice;
    }

    public void setGprice(BigDecimal gprice) {
        this.gprice = gprice;
    }

    public int getGnumber() {
        return gnumber;
    }

    public void setGnumber(int gnumber) {
        this.gnumber = gnumber;
    }

    public String getGcid() {
        return gcid;
    }

    public void setGcid(String gcid) {
        this.gcid = gcid;
    }

    public String getGdetail() {
        return gdetail;
    }

    public void setGdetail(String gdetail) {
        this.gdetail = gdetail;
    }


    @Override
    public String toString() {
        return "Goods{" +
                "gid=" + gid +
                ", gname='" + gname + '\'' +
                ", guid=" + guid +
                ", gtime=" + gtime +
                ", gprice=" + gprice +
                ", gnumber=" + gnumber +
                ", gcid='" + gcid + '\'' +
                ", gdetail='" + gdetail + '\'' +
                ", guname='" + guname + '\'' +
                ", gimgfile=" + gimgfile +
                ", gimg_path='" + gimg_path + '\'' +
                ", gtinyint=" + gtinyint +
                '}';
    }
}
